package fr.vvins.core.services;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import fr.vvins.core.biz.exception.BizException;
import fr.vvins.core.biz.order.dto.OrderDto;
import fr.vvins.core.biz.order.dto.PaymentItemDto;
import fr.vvins.core.biz.order.dto.ShippingItemDto;
import fr.vvins.core.common.TechnicalException;

/**
 * OrderService group all methods related to order process.
 * 
 * @author fguay
 */
public interface OrderService {
	
	
	/**
	 * Return the current user's order.<BR>
	 * Method : GET<BR>
	 * Path : "/order/current?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * Consumes :  MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@GET
	@Path("/current")
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto getCurrentOrder(@QueryParam("token") String token) throws BizException, TechnicalException;

	/**
	 * Create a new user's order.<BR>
	 * Method : PUT<BR>
	 * Path : "/order/current?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * Consumes :  MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @return
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@PUT
	@Path("/current")
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto createNewOrder(@QueryParam("token") String token) throws BizException, TechnicalException;

	/**
	 * Delete current user's order.<BR>
	 * Method : DELETE<BR>
	 * Path : "/order/current?token={token}<BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@DELETE
	@Path("/current")
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto deleteCurrentOrder(@QueryParam("token") String token) throws BizException, TechnicalException;

	/**
	 * Add a new commerce item to current order.<BR>
	 * Method : PUT<BR>
	 * Path : "/order/item/{skuId}/{quantity}?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * Consumes :  MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @param skuId
	 * @param quantity
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@PUT
	@Path("/item/{id}/{quantity}")
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto addItem(@QueryParam("token") String token, @PathParam("id") String skuId, @PathParam("quantity") String quantity) throws BizException, TechnicalException;

	/**
	 * Remove commerce item of current order.<BR>
	 * Method : DELETE<BR>
	 * Path : "/order/item/{skuId}/{quantity}?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @param skuId
	 * @param quantity
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@DELETE
	@Path("/item/{sku}/{quantity}")
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto removeItem(@QueryParam("token") String token, @PathParam("id") String skuId, @PathParam("quantity") String quantity) throws BizException, TechnicalException;

	/**
	 * Add payment method to current order.<BR>
	 * Method : PUT<BR>
	 * Path : "/order/payment?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * Consumes :  MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @param payment
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@PUT
	@Path("/payment")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto addPayment(@QueryParam("token") String token, PaymentItemDto payment) throws BizException, TechnicalException;
	
	/**
	 * Remove payment method to curent order.<BR>
	 * Method : DELETE<BR>
	 * Path : "/order/payment/{paymentId}?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @param paymentId
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@DELETE
	@Path("/payment/{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto removePayment(@QueryParam("token") String token, @PathParam("id") String paymentId) throws BizException, TechnicalException;
	
	/**
	 * Add shipping method to current user order.<BR>
	 * Method : PUT<BR>
	 * Path : "/order/shipping?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * Consumes :  MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @param shipping
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@PUT
	@Path("/shipping")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)	
	public OrderDto addShipping(@QueryParam("token") String token, ShippingItemDto shipping) throws BizException, TechnicalException;
	
	/**
	 * Remove shipping method to current user order.<BR>
	 * Method : DELETE<BR>
	 * Path : "/order/shipping/{shippingId}?token={token}" <BR>
	 * Produces : MediaType.APPLICATION_JSON<BR>
	 * Consumes :  MediaType.APPLICATION_JSON<BR>
	 * 
	 * @param token : current user token
	 * @param shippingId
	 * @return Order object
	 * @throws BizException
	 * @throws TechnicalException
	 */
	@DELETE
	@Path("/shipping/{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public OrderDto removeShipping(@QueryParam("token") String token,  @PathParam("id") String shippingId) throws BizException, TechnicalException;
	
	

}
